/* header.h
 * 
 * Copyright (C) 3 September, 2005 Priyank Bolia
 * http://www.priyank.in
 * 
 * This code is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This code is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the Free
 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
 * MA 02111-1307, USA
 */

#pragma once

class CCanvas : public wxPanel
{
private:
	class CHead;
	class CBody;
	class CFoot;
	class CImageNavigator;

public:
	virtual ~CCanvas(void);

public:
    CCanvas( 
		wxWindow *parent, wxWindowID id = 1, 
		const wxPoint& pos = wxDefaultPosition, 
		const wxSize& size = wxDefaultSize, 
		long style = wxTAB_TRAVERSAL
		);

private:
	enum
	{
		BUTTON_1 = 1,
		BUTTON_2,
		BUTTON_3,
		BUTTON_4,
	};

	wxList m_buttons;

	CHead* m_pHead;
	CBody* m_pBody;
	CFoot* m_pFoot;

public:
	void SetImage(wxImage image);
	void SetZoomScale(float fZoomScale);

private:
    DECLARE_EVENT_TABLE()


private:
	///
	/// CHead
	///
	class CHead : public wxPanel
	{
	public:
		virtual ~CHead(void);

	public:
		CHead( 
			wxWindow *parent, wxWindowID id = 1, 
			const wxPoint& pos = wxDefaultPosition, 
			const wxSize& size = wxDefaultSize, 
			long style = wxTAB_TRAVERSAL
			);

	private:
		wxBoxSizer* m_pSizer;
		wxButton* m_pButtonUndo;
		wxSlider* m_pSliderZoom;

	private:
		enum
		{
			ID_BUTTON_UNDO		= 1,
			ID_SLIDER_ZOOM		= 2,
		};

	private:
		void OnPaint(wxPaintEvent& event);
		void OnScroll(wxScrollEvent& event);
		DECLARE_EVENT_TABLE()
	};

	///
	/// CBody
	///
	class CBody : public wxPanel
	{
	public:
		virtual ~CBody(void);

	public:
		CBody( 
			wxWindow *parent, wxWindowID id = 1, 
			const wxPoint& pos = wxDefaultPosition, 
			const wxSize& size = wxDefaultSize, 
			long style = wxTAB_TRAVERSAL
			);
	public:
		void SetImage(wxImage image);
		void SetZoomScale(float fZoomScale);

	private:
		void BuildCache();
		void RepositionImageNavigator();

	private:
		wxImage m_Image;
		float m_fZoomScale;
		wxImage m_Cache;

		CImageNavigator* m_pImageNavigator;


	private:
		void OnPaint(wxPaintEvent& event);
		void OnEraseBackGround(wxEraseEvent& event);
		void OnSize(wxSizeEvent& event);
		DECLARE_EVENT_TABLE()
	};


	///
	/// CFoot
	///
	class CFoot : public wxPanel
	{
	public:
		virtual ~CFoot(void);

	public:
		CFoot( 
			wxWindow *parent, wxWindowID id = 1, 
			const wxPoint& pos = wxDefaultPosition, 
			const wxSize& size = wxDefaultSize, 
			long style = wxTAB_TRAVERSAL
			);

	/// Methods
	public:

	private:
		void OnPaint(wxPaintEvent& event);
		DECLARE_EVENT_TABLE()
	};

	///
	class CImageNavigator : public wxWindow
	{
	public:
		virtual ~CImageNavigator(void);

	public:
		CImageNavigator( 
			wxWindow *parent, wxWindowID id = 1, 
			const wxPoint& pos = wxDefaultPosition, 
			const wxSize& size = wxDefaultSize, 
			long style = wxTAB_TRAVERSAL
			);

	/// Methods
	public:

	private:
		void OnEraseBackGround(wxEraseEvent& event);
		void OnPaint(wxPaintEvent& event);
		DECLARE_EVENT_TABLE()
	};
};